package com.cruise.biztest1;

import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 类名：biztest1App
 * 描述：TODO
 * @author ：Cruise
 * 日期：2021/1/17 下午3:38
 * 版本：1.0
 */

@ComponentScan(basePackages={"com.cruise.biztest1", "com.cruise.common"})
@EnableEurekaClient
@SpringBootApplication
@EnableSwagger2
@EnableDistributedTransaction
@EnableFeignClients("com.cruise.biztest2.api.feign")
public class Biztest1App {

    static Logger logger= LoggerFactory.getLogger(Biztest1App.class);

    public static void main(String[] args) throws UnknownHostException {

        ConfigurableApplicationContext application = SpringApplication.run(Biztest1App.class, args);

        Environment env = application.getEnvironment();
        String host= InetAddress.getLocalHost().getHostAddress();
        String port=env.getProperty("server.port");
        logger.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "External: \thttp://{}:{}\n\t"+
                        "Doc: \thttp://{}:{}/doc.html\n\t"+
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                host,port,
                host,port);
    }
}
